<?php
namespace app\myr\controller;
use think\facade\Db;
use think\admin\Controller;
use think\admin\helper\QueryHelper;
use think\admin\model\WxBos;
use app\myr\model\Deliveryorderfahuodetail;

/**
 * 发货溯源管理
 */
class Fahuoshuyuan extends Controller
{
    public $table = '';
    /**
     * 发货溯源列表
     * @auth true  # 表示需要验证权限
     * @menu true  # 添加系统菜单节点
     * @login true # 强制登录才可访问
     */
    public function index(){
        Deliveryorderfahuodetail::mQuery()->layTable(function () {
            $this->title = '发货溯源列表';
        }, static function (QueryHelper $query) {
           $query->like("boxcode,sncode,wdbh,wd_name,order_no,is_qianshou,custcode,is_return")->dateBetween('qs_time');
        });
    }
    
    /**
     * 列表数据处理
     */
    protected function _index_page_filter(&$data)
    {
        foreach ($data as &$vo) {
            $is_qianshou=$vo["is_qianshou"];
            if($vo["is_qianshou"] == 1){  $vo["is_qianshou"]="已签收"; }
            else if($vo["is_qianshou"] == 0){ $vo["is_qianshou"]="待签收"; }
            if($vo["qs_time"]){
              $vo["qs_time"]=date("Y-m-d H:i:s",$vo["qs_time"]);  
            }
            $vo["add_time"]=date("Y-m-d H:i:s",$vo["add_time"]);  
            $is_send=Db::name("jxs_kucun")->where(["jxs_code"=>$vo["wdbh"],"sncode"=>$vo["sncode"]])->order("id desc")->value("is_send");
            //$is_send=$vo["is_send"];
            if($is_send == 1){ $vo["is_send"]="已下发";}
            else if($is_send == 0){ $vo["is_send"]="在库";}
            else if($is_send == 2){ $vo["is_send"]="退货";}
            if($vo["is_return"] == 1){
                $vo["is_send"]="退货";
            }
            if($is_qianshou == 0){
                $vo["is_send"]="否";
            }
            
       }
    }
    
      

    
    
   
}